import { _decorator, Component, Enum, view } from "cc";
import { SetBasicInfo } from "../Utils/SetBasicInfo";
const { ccclass, property } = _decorator;

export enum RewardType {
  TwoShoot,
  Bomb,
}

@ccclass("Reward")
export class Reward extends Component {
  // 屏幕宽高
  pageWidth: number = 0;
  pageHeight: number = 0;
  
  @property({ type: Enum(RewardType), displayName: "奖励类型" })
  rewardType: RewardType = RewardType.TwoShoot;

  // 速度
  @property
  speed: number = 100;

  start() {}

  /**
   * 获取背景高度
   */
  getBgHeight() {
    const { width, height } = view.getVisibleSize();
    this.pageWidth = width;
    this.pageHeight = height;
  }

  update(deltaTime: number) {
    const position = this.node.position;
    SetBasicInfo.setPosition(this.node, {
      y: position.y - this.speed * deltaTime,
    });

    if (position.y < -this.pageHeight) {
      this.node?.destroy();
    }
  }
}
